﻿var file_type = "";
function sleep(milliseconds) {
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++) {
        if ((new Date().getTime() - start) > milliseconds) {
            break;
        }
    }
}
function readURL2(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {

            var split = e.target.result.toString().split("/");
            file_type = split[0];
            if (split[0] == "data:image") {
                document.getElementById("audio_upload").style.display = "none";
                document.getElementById("img_upload").style.display = "inline-block";
                document.getElementById("upload_name").style.display = "block";
                $('#img_upload').attr('src', e.target.result);
            }
            else {
                if (split[0] == "data:audio") {
                    document.getElementById("audio_upload").style.display = "inline-block";
                    document.getElementById("img_upload").style.display = "none";
                    $('#audio_upload').attr('src', e.target.result);
                    document.getElementById("upload_name").style.display = "block";
                }
                else {
                    document.getElementById("audio_upload").style.display = "none";
                    document.getElementById("img_upload").style.display = "none";
                    document.getElementById("upload_name").style.display = "none";
                }
            }
        }

        reader.readAsDataURL(input.files[0]);
    }
}
$(document).ready(function () {

    //$(document).keypress(function (event) {
    //    var keycode = (event.keyCode ? event.keyCode : event.which);
    //    if (keycode == '13') {
    //        if ($(".gal-search-input").attr("style") == "display: inline-block;") {
    //            search();
    //        }
    //    }
    //});

    $(".gal-search-input").change(function () {
        search();
    });
    $("#fileUpload").change(function () {
        readURL2(this);
    });
    $(document).ready(function () {
        $('[data-toggle="tooltip"]').tooltip();
    });
    $(".gal-search-btn").click(function () {
        $(".gal-search-input").animate({ width: "toggle" }, "800");
        this.style.display = "none";
        $(".gal-close-search-btn").animate({ width: "toggle" }, "800");
    });
    $(".gal-close-search-btn").click(function () {
        $(".gal-search-input").animate({ width: "toggle" }, "800");
        this.style.display = "none";
        $(".gal-search-btn").animate({ width: "toggle" }, "800");
    });
    $(".gal-view-type-btn").click(function () {
        $("#xemkieugi").fadeIn();
    });
    $(".gal-menu a").click(function () {
        $(".gal-menu a").removeClass("gal-menu-item-active");
        $(".gal-menu a").children("i").removeClass("w3-text-teal");
        $(this).addClass("gal-menu-item-active");
        $(this).children("i").addClass("w3-text-teal");
    });
    $("#btn_upload_file").click(function () {
        var file = document.getElementById("fileUpload").value;
        var name = document.getElementById("txt_file_name").value;
        var parent = document.getElementsByClassName("gal-active")[0].getElementsByClassName("folder_id")[0].innerHTML;
        if (file != "") {
            if (file_type != "data:image" && file_type != "data:audio") {
                alert("Tập tin này không thuộc hình ảnh hoặc âm thanh");
            }
            else {
                if (name != "") {
                    var file_data = document.getElementById('fileUpload').files[0];
                    if (file_data == null) return; // chưa chọn file
                    var form_data = new FormData();
                    form_data.append("fileUpload", file_data);
                    $.ajax({
                        url: '../ajax/asp/certificate/upload.aspx?type=' + file_type + "&name=" + name.trim() + "&parent=" + parent,
                        data: form_data,
                        processData: false,
                        contentType: false,
                        type: 'POST',
                        success: function (data) {
                            //$("#divTreeView").html(data);
                        }
                    });
                    document.getElementById("fileUpload").value = "";
                    document.getElementById("txt_file_name").value = "";
                    document.getElementById("upload_name").style.display = "none";
                    document.getElementById("audio_upload").style.display = "none";
                    document.getElementById("img_upload").style.display = "none";
                    document.getElementById("themtaptin").style.display = "none";
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            var temp = document.getElementById("item_area").innerHTML;

                            document.getElementById("item_area").innerHTML = xhttp.responseText;
                            document.getElementById("item_area").innerHTML += temp;
                            $(".gal-table-data tr").click(function () {
                                if ($(this).parent().children("tr").hasClass("clicked")) {
                                    $(".clicked").removeClass("w3-teal");
                                    $(".clicked").removeClass("clicked");
                                    $(this).addClass("clicked")
                                    $(this).addClass("w3-teal");
                                }
                                else {
                                    $(this).addClass("clicked")
                                    $(this).addClass("w3-teal");
                                }
                            });
                            $(document).ready(function () {
                                $('[data-toggle="tooltip"]').tooltip();
                            });
                            if (file_type == "data:image") {
                                document.getElementById("success-modal").style.display = "block";
                                document.getElementById("success_content").innerHTML = "Upload hình ảnh thành công";
                                setTimeout("$('#success-modal').fadeOut()", 3000);
                            }
                            else {
                                document.getElementById("success-modal").style.display = "block";
                                document.getElementById("success_content").innerHTML = "Upload âm thanh thành công";
                                setTimeout("$('#success-modal').fadeOut()", 3000);
                            }
                        }
                    };
                    sleep(5000);
                    xhttp.open("GET", "../ajax/asp/Gallery/create_File.aspx", true);
                    xhttp.send();

                }
                else {
                    alert("Bạn chưa đặt tên cho tập tin này");
                }
            }
        }
        else {
            alert("Không có file để Upload");
        }
    });
    $("#btn_upload_video").click(function () {
        var link = document.getElementById("txt_video_link").value;
        var name = document.getElementById("txt_video_name").value;
        var parent = document.getElementsByClassName("gal-active")[0].getElementsByClassName("folder_id")[0].innerHTML;
        if (link == "") {
            alert("Bạn chưa nhập đường dẫn cho video");
        }
        else {
            if (name == "") {
                alert("Bạn chưa đặt tên cho video");
            }
            else {
                document.getElementById("txt_video_link").value = "";
                document.getElementById("txt_video_name").value = "";
                document.getElementById("themvideo").style.display = "none";
                var xhttp;
                xhttp = new XMLHttpRequest();
                xhttp.onreadystatechange = function () {
                    if (xhttp.readyState == 4 && xhttp.status == 200) {
                        var temp = document.getElementById("item_area").innerHTML;

                        document.getElementById("item_area").innerHTML = xhttp.responseText;
                        document.getElementById("item_area").innerHTML += temp;
                        $(".gal-table-data tr").click(function () {
                            if ($(this).parent().children("tr").hasClass("clicked")) {
                                $(".clicked").removeClass("w3-teal");
                                $(".clicked").removeClass("clicked");
                                $(this).addClass("clicked")
                                $(this).addClass("w3-teal");
                            }
                            else {
                                $(this).addClass("clicked")
                                $(this).addClass("w3-teal");
                            }
                        });
                        $(document).ready(function () {
                            $('[data-toggle="tooltip"]').tooltip();
                        });
                        document.getElementById("success-modal").style.display = "block";
                        document.getElementById("success_content").innerHTML = "Thêm Video thành công";
                        setTimeout("$('#success-modal').fadeOut()", 3000);
                    }
                };
                xhttp.open("GET", "../ajax/asp/Gallery/create_Video.aspx?name=" + name + "&link=" + link + "&parent=" + parent, true);
                xhttp.send();
            }
        }
    });
    //$(".gal-show-folder-btn").click(function () {
    //    if ($(this).parent().parent().children(".gal-sub-menu").hasClass("opened")) {
    //        $(this).parent().parent().children(".gal-sub-menu").removeClass("opened");
    //        $(this).parent().parent().children(".gal-sub-menu").animate({ height: "toggle" }, "fast");
    //        $(this).removeClass("fa-rotate-90");
    //    }
    //    else {
    //        $(this).parent().parent().children(".gal-sub-menu").addClass("opened");
    //        $(this).parent().parent().children(".gal-sub-menu").animate({ height: "toggle" }, "fast");
    //        $(this).addClass("fa-rotate-90");
    //    }
    //});
    $(".gal-table-sort-name").click(function () {
        if ($(this).children("i").hasClass("gal-table-sort-effect")) {
            $(this).children("i").removeClass("gal-table-sort-effect");
            $(this).removeClass("gal-table-sort-active");
        }
        else {
            $(this).children("i").addClass("gal-table-sort-effect");
            $(this).addClass("gal-table-sort-active");
        }
    });
    $(".gal-table-data tr").click(function () {
        if ($(this).parent().children("tr").hasClass("clicked")) {
            $(".clicked").removeClass("w3-teal");
            $(".clicked").removeClass("clicked");
            $(this).addClass("clicked")
            $(this).addClass("w3-teal");
        }
        else {
            $(this).addClass("clicked")
            $(this).addClass("w3-teal");
        }
    });
});

function open_folder(id, name) {
    var count = $(".gal-all-folder-item .gal-menu-item").length;
    document.getElementById("folder_area").innerHTML = "<div id='loading'><div id='loading-center-absolute'><div class='object w3-text-teal' id='object_four'></div><div class='object w3-text-teal' id='object_three'></div><div class='object w3-text-teal' id='object_two'></div><div class='object w3-text-teal' id='object_one'></div></div></div>";
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("folder_area").innerHTML = xhttp.responseText;
            $(".gal-table-data tr").click(function () {
                if ($(this).parent().children("tr").hasClass("clicked")) {
                    $(".clicked").removeClass("w3-teal");
                    $(".clicked").removeClass("clicked");
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
                else {
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
            });
            $(document).ready(function () {
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/open_Folder.aspx?id=" + id, true);
    xhttp.send();
}
function btn_create_folder() {
    var name = document.getElementById("txt_Folder_Name").value;
    var parent = document.getElementsByClassName("gal-active")[0].getElementsByClassName("folder_id")[0].innerHTML;
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            var temp = document.getElementById("item_area").innerHTML;

            document.getElementById("item_area").innerHTML = xhttp.responseText;
            document.getElementById("item_area").innerHTML += temp;
            $(".gal-table-data tr").click(function () {
                if ($(this).parent().children("tr").hasClass("clicked")) {
                    $(".clicked").removeClass("w3-teal");
                    $(".clicked").removeClass("clicked");
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
                else {
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
            });
            $(document).ready(function () {
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/create_Folder.aspx?name=" + name + "&parent=" + parent, true);
    xhttp.send();
    $("#themthumuc").fadeOut();
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Tạo Thư Mục thành công";
    setTimeout("$('#success-modal').fadeOut()", 3000);
}

function search() {
    document.getElementById("allfolder").style.display = "block";
    var search = document.getElementById("txt_search_file").value;
    document.getElementById("folder_title_area").innerHTML = '<span class="gal-title gal-active w3-text-teal"><i class="w3-hide folder_id">0</i>' + search + '</span>';
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("folder_area").innerHTML = xhttp.responseText;
            $(".gal-table-data tr").click(function () {
                if ($(this).parent().children("tr").hasClass("clicked")) {
                    $(".clicked").removeClass("w3-teal");
                    $(".clicked").removeClass("clicked");
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
                else {
                    $(this).addClass("clicked")
                    $(this).addClass("w3-teal");
                }
            });
            $(document).ready(function () {
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/search_File.aspx?search=" + search, true);
    xhttp.send();
}

function btn_move() {
    var id = document.getElementById("move_id").innerHTML;
    var folder_current = document.getElementsByClassName("gal-active")[0].getElementsByClassName("folder_id")[0].innerHTML;
    try {
        var folder_id = document.getElementsByClassName("gal-menu-item-active")[0].getElementsByClassName("folder_id")[0].innerHTML;
        $.post("../Ajax/ASP/Gallery/accept_move_File.aspx", { "id": id, "folder_id": folder_id });
        if (folder_current != folder_id)
            $("#item" + id).remove();
        document.getElementById("success-modal").style.display = "block";
        document.getElementById("success_content").innerHTML = "Chuyển thư mục thành công";
        setTimeout("$('#success-modal').fadeOut()", 3000);
        $('#gal-move').fadeOut()
    }
    catch (e) {
        document.getElementById("error-modal").style.display = "block";
        document.getElementById("error_content").innerHTML = "Hãy chọn thư mục để di chuyển đến";
        setTimeout("$('#error-modal').fadeOut()", 3000);
    }
}
function gal_sub_menu() {
    var sub_menu = document.getElementsByClassName("gal-sub-menu");
    for (var i = 0; i < sub_menu.length; i++) {
        sub_menu[i].style.padding = "0 0 0 14px";
    }
}

function select_folder(count) {
    $(".gal-all-folder-item .gal-menu-item i").removeClass("w3-text-teal");
    $(".gal-all-folder-item .gal-menu-item").removeClass("gal-menu-item-active");

    $(".gal-all-folder-item .gal-menu-item").slice(count - 1).find("i").addClass("w3-text-teal");
    $(".gal-all-folder-item .gal-menu-item").slice(count - 1).addClass("gal-menu-item-active");
}

function gal_open_menu_left(evt, menutarget, parent) {
    $("#gal_Create").fadeIn();
    var i, x;
    x = document.getElementsByClassName("gal-right-content");
    for (i = 0; i < x.length; i++) {
        x[i].style.display = "none";
    }
    document.getElementById(menutarget).style.display = "block";
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            if ($("#folderLeft" + parent).length) {
                document.getElementById("folderLeft" + parent).innerHTML = xhttp.responseText;

                if ($("#folderLeft" + parent).hasClass("opened")) {
                    //$("#folderLeft" + parent).removeClass("opened");
                    //$("#folderLeft" + parent).animate({ height: "toggle" }, "fast");
                    //$("#folderLeft" + parent).parent().children(".gal-menu-item").children(".gal-show-folder-btn").removeClass("fa-rotate-90");
                }
                else {
                    $("#folderLeft" + parent).addClass("opened");
                    $("#folderLeft" + parent).animate({ height: "toggle" }, "fast");
                    $("#folderLeft" + parent).parent().children(".gal-menu-item").children(".gal-show-folder-btn").addClass("fa-rotate-90");
                }
            }
            gal_sub_menu();
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/open_Folder_Left.aspx?parent=" + parent, true);
    xhttp.send();
}

function title_top_default() {
    document.getElementById("folder_title_area").innerHTML = '<span class="gal-title gal-active w3-text-teal"><i class="w3-hide folder_id">0</i>Tất cả thư mục</span>';
}
function title_top(id) {
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("folder_title_area").innerHTML = xhttp.responseText;
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/get_title_folder.aspx?id=" + id, true);
    xhttp.send();
}

function gal_restore(id) {
    $.post("../Ajax/asp/Gallery/restore_File.aspx", { "id": id });
    $("#item" + id).remove();
    var count = document.getElementById("count_trash").innerHTML;
    count--;
    document.getElementById("count_trash").innerHTML = count;
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Khôi phục thành công";
    setTimeout("$('#success-modal').fadeOut()", 3000);
}

function gal_open_trash(evt, menutarget) {
    document.getElementById(menutarget).style.display = "block";
    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            document.getElementById("folder_area").innerHTML = xhttp.responseText;
            $(document).ready(function () {
                $('[data-toggle="tooltip"]').tooltip();
            });
            gal_sub_menu();
            $(".gal-menu a").click(function () {
                $(".gal-menu a").removeClass("gal-menu-item-active");
                $(".gal-menu a").children("i").removeClass("w3-text-teal");
                $(this).addClass("gal-menu-item-active");
                $(this).children("i").addClass("w3-text-teal");
            });

            document.getElementById("folder_title_area").innerHTML = '<span class="gal-title gal-active w3-text-teal">Thùng rác</span>';
            $("#gal_Create").fadeOut();
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/open_Trash.aspx", true);
    xhttp.send();

}
function gal_open_menu(evt, menutarget, parent) {
    var i, x;
    var id = document.getElementById("move_id").innerHTML;
    x = document.getElementsByClassName("gal-right-content");
    for (i = 0; i < x.length; i++) {
        x[i].style.display = "none";
    }
    document.getElementById(menutarget).style.display = "block";

    var xhttp;
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function () {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
            if ($("#folder" + parent).length) {
                document.getElementById("folder" + parent).innerHTML = xhttp.responseText;
                if ($("#folder" + parent).hasClass("opened")) {
                    $("#folder" + parent).removeClass("opened");
                    $("#folder" + parent).animate({ height: "toggle" }, "fast");
                    $("#folder" + parent).parent().children(".gal-menu-item").children(".gal-show-folder-btn").removeClass("fa-rotate-90");
                }
                else {
                    $("#folder" + parent).addClass("opened");
                    $("#folder" + parent).animate({ height: "toggle" }, "fast");
                    $("#folder" + parent).parent().children(".gal-menu-item").children(".gal-show-folder-btn").addClass("fa-rotate-90");
                }
            }
            gal_sub_menu();
            $(".gal-menu a").click(function () {
                $(".gal-menu a").removeClass("gal-menu-item-active");
                $(".gal-menu a").children("i").removeClass("w3-text-teal");
                $(this).addClass("gal-menu-item-active");
                $(this).children("i").addClass("w3-text-teal");
            });
        }
    };
    xhttp.open("GET", "../ajax/asp/Gallery/move_File.aspx?id=" + id + "&parent=" + parent, true);
    xhttp.send();
}

function gal_copy(id) {
    document.querySelector("#link" + id).select();
    document.execCommand('copy');
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Đường dẫn đã được copy";
    setTimeout("$('#success-modal').fadeOut()", 3000);
}
function gal_rename(name, id) {
    document.getElementById("rename_Gal").value = name;
    document.getElementById("gal-rename").style.display = "block";
    document.getElementById("rename_id").innerHTML = id;
}
function gal_move(id) {
    if ($("#folder0").hasClass("opened")) {
        $("#folder0").removeClass("opened");
        $("#folder0").animate({ height: "toggle" }, "fast");
        $("#folder0").parent().children(".gal-menu-item").children(".gal-show-folder-btn").removeClass("fa-rotate-90");
    }
    document.getElementById("move_id").innerHTML = id;
    document.getElementById("gal-move").style.display = "block";
}
function btn_delete() {
    var id = document.getElementById("delete_id").innerHTML;
    $.post("../ajax/asp/gallery/delete_file.aspx", { "id": id });
    $("#gal-delete").fadeOut();
    var itemImg = $("#item" + id).find(".gal-table-name");
    flyToElement($(itemImg), $('.trash-icon'));
    document.getElementById("item" + id).style.display = "none";
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Tập tin đã được chuyển vào Thùng rác";
    setTimeout("$('#success-modal').fadeOut()", 3000);
    if (!$("#count_trash").length) {
        document.getElementById("open_trash").innerHTML += "(<label id='count_trash'>0</label>)";
    }
    var count = document.getElementById("count_trash").innerHTML;
    count++;
    document.getElementById("count_trash").innerHTML = count;
}
function gal_delete(id) {
    document.getElementById("gal-delete").style.display = "block";
    document.getElementById("delete_id").innerHTML = id;
}
function btn_rename() {
    var name = document.getElementById("rename_Gal").value;
    var id = document.getElementById("rename_id").innerHTML;
    document.getElementById("item" + id).getElementsByClassName("item_name")[0].innerHTML = name;
    $.post("../Ajax/ASP/Gallery/rename_File.aspx", { "id": id, "name": name });
    $("#gal-rename").fadeOut();
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Đổi tên thành công";
    setTimeout("$('#success-modal').fadeOut()", 3000);
}
function gal_detroy(id) {
    document.getElementById("detroy_id").innerHTML = id;
    document.getElementById("gal-detroy").style.display = "block";
}

function btn_detroy() {
    var id = document.getElementById("detroy_id").innerHTML;
    $.post("../Ajax/ASP/Gallery/detroy_File.aspx", { "id": id });
    $("#gal-detroy").fadeOut();
    $("#item" + id).fadeOut();
    var count = document.getElementById("count_trash").innerHTML;
    count--;
    document.getElementById("count_trash").innerHTML = count;
    document.getElementById("success-modal").style.display = "block";
    document.getElementById("success_content").innerHTML = "Xóa tập tin thành công";
    setTimeout("$('#success-modal').fadeOut()", 3000);
}
function gal_play_audio(evt, link) {
    for (var i = 0; i < document.getElementsByClassName("gal-stop-audio-btn").length; i++) {
        document.getElementsByClassName("gal-stop-audio-btn")[i].style.display = "none";
        document.getElementsByClassName("gal-play-audio-btn")[i].style.display = "inline-block";
    }
    evt.currentTarget.style.display = "none";
    evt.currentTarget.parentElement.getElementsByClassName("gal-stop-audio-btn")[0].style.display = "inline-block";
    document.getElementById("gallery_audio").src = "../Content/testdata/audio/" + link;
    document.getElementById("gallery_audio").play();

    setInterval(stop_Audio, "1000");
}
function stop_Audio() {
    var duration = document.getElementById("gallery_audio").duration;
    var currentTime = document.getElementById("gallery_audio").currentTime;
    if (parseInt(duration) == parseInt(currentTime)) {
        for (var i = 0; i < document.getElementsByClassName("gal-stop-audio-btn").length; i++) {
            document.getElementsByClassName("gal-stop-audio-btn")[i].style.display = "none";
            document.getElementsByClassName("gal-play-audio-btn")[i].style.display = "inline-block";
        }
    }
}

function gal_stop_audio(evt) {
    evt.currentTarget.style.display = "none";
    evt.currentTarget.parentElement.getElementsByClassName("gal-play-audio-btn")[0].style.display = "inline-block";
    document.getElementById("gallery_audio").pause();
}
function gal_view_img(img, name) {
    document.getElementById("gal-view-img-target").src = img.src;
    var imgname = document.getElementById("gal-view-img-name");
    imgname.innerHTML = name;
    $(".admin-main-menu").animate({ width: "toggle" }, "fast");
    document.getElementsByClassName("admin-main-content")[0].style.marginLeft = "0px";
    $("#gal-view-img-modal").fadeIn();
}
function gal_close_img() {
    $(".admin-main-menu").animate({ width: "toggle" }, "fast");
    document.getElementsByClassName("admin-main-content")[0].style.marginLeft = "60px";
    $("#gal-view-img-modal").fadeOut();
}
function gal_watch_video(video) {
    $(".admin-main-menu").animate({ width: "toggle" }, "fast");
    document.getElementsByClassName("admin-main-content")[0].style.marginLeft = "0px";
    document.getElementById("gal-watch-video-target").src = "https://www.youtube-nocookie.com/embed/" + video.parentElement.getElementsByClassName("gal-video-link")[0].innerHTML + "?rel=0&amp;showinfo=0";
    var videoname = document.getElementById("gal-watch-video-name");
    videoname.innerHTML = video.parentElement.getElementsByClassName("gal-video-name")[0].innerHTML;
    $("#gal-watch-video-modal").fadeIn();
}
function gal_stop_video() {
    document.getElementById("gal-watch-video-target").src = "";
    $(".admin-main-menu").animate({ width: "toggle" }, "fast");
    document.getElementsByClassName("admin-main-content")[0].style.marginLeft = "60px";
    $("#gal-watch-video-modal").fadeOut();
}
